package com.cx.controller;

import com.cx.domain.user;
import com.cx.service.userservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@Component
@RequestMapping
public class From {
    @Autowired
    private user user;
    @Autowired
    private userservice userservice;
//    @RequestMapping("/From")
//    public void From(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//        String name = request.getParameter("username");
//        String password = request.getParameter("password");
//        request.getSession().setAttribute("name",name);
//        request.getSession().setAttribute("password",password);
//        if (userservice.save1(name) != null && password.equals(userservice.save1(name))) {
//            user.setUserName(name);
//            user.setUserPWD(password);
//            request.getSession().setAttribute("user", user);
//            request.getRequestDispatcher("page/首页.jsp").forward(request,response);
//        }
//        String msg="密码不正确";
//        request.getSession().setAttribute("msg",msg);
//        request.getRequestDispatcher("index.jsp").forward(request,response);
//    }
//    @RequestMapping("/register")
//    public void register(HttpServletRequest request,HttpServletResponse response) throws ServletException, IOException {
//        try {
//            userservice.insert(request.getParameter("uid"),request.getParameter("password"),request.getParameter("age"),request.getParameter("name"));
//            request.getSession().setAttribute("msg1","注册成功");
//        } catch (Exception e) {
//            request.getSession().setAttribute("msg1","uid已存在");
//        }
//        request.getRequestDispatcher("index.jsp").forward(request,response);
//    }
}
